﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using Setup;
using System.Diagnostics;

namespace NasuTek.Shion
{
    public partial class XULRunnerDownloader : Form
    {
        public XULRunnerDownloader()
        {
            InitializeComponent();
        }

        private void XULRunnerDownloader_Load(object sender, EventArgs e)
        {
            WebClient client = new WebClient();
            client.DownloadFileAsync(new Uri("http://nasutek.com/shion/xulrunner-1.9.0.10.en-US.win32.zip"), "xulrunner.zip");
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
            client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
        }

        void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            Unzip.UnZipFiles("xulrunner.zip", Application.StartupPath, "", true);
            this.Close();
            Process.Start("NasuTek.Shion.exe");
        }

        void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            Invoke(new Action(delegate { progressBar1.Value = e.ProgressPercentage; }));
        }
    }
}
